//
//  LLMeController.m
//  Weibo
//
//  Created by 李灵斌 on 15-1-28.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "LLMeController.h"
#import "LLDefaultView.h"
#import "LLProductCell.h"
#import "LLProductGroup.h"
#import "LLProductItem.h"
#import "LLProductArrowItem.h"
#import "LLProductLabItem.h"
#import "LLProductSwitchItem.h"
@interface LLMeController ()
@property (nonatomic, strong) NSMutableArray *datas;
@end

@implementation LLMeController

- (instancetype)init{
    
    if (self = [super initWithStyle:UITableViewStyleGrouped]) {
        
    }
    return self;
}

- (NSMutableArray *)datas{
    
    if (!_datas) {
        _datas = [NSMutableArray array];
    }
    return _datas;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置导航条上的item按钮
    [self setupRightItem];
    
    if (self.defaultView != nil) {
        // 设置默认界面
        self.defaultView.iconView.image =[UIImage imageNamed: @"visitordiscover_image_profile"];
        self.defaultView.contentLab.text = @"登陆后,你的微博、相册、个人资料会显示在这里， 展示给别人";
        self.defaultView.animatePic.hidden = YES;
    } else {
       
        // 设置数据
        [self setupGroups];
        
        // 设置tableView
        [self setupTableView];
        
    }
}

#pragma mark - 设置tableView
- (void)setupTableView{
    
    self.tableView.sectionHeaderHeight = 0;
    self.tableView.sectionFooterHeight = 10;
    self.tableView.backgroundColor = LLColor(232, 233, 232);
    
    self.tableView.contentInset = UIEdgeInsetsMake(-25, 0, 0, 0);
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched;
}

#pragma mark - 设置数据
- (void)setupGroups{
    
    [self setupGroup0];
    [self setupGroup1];
    [self setupGroup2];
    [self setupGroup3];
}

- (void)setupGroup0{
    
    LLProductGroup *group0 = [[LLProductGroup alloc] init];
    [self.datas addObject:group0];
    LLProductArrowItem *newFriend = [[LLProductArrowItem alloc] initWithTitle:@"新的好友"icon:@"new_friend"];
    group0.items = @[newFriend];
}

- (void)setupGroup1{
    
    LLProductArrowItem *album = [[LLProductArrowItem alloc] initWithTitle:@"我的相册" icon:@"album"];
    LLProductArrowItem *collect = [[LLProductArrowItem alloc] initWithTitle:@"我的收藏" icon:@"collect"];
    
    LLProductArrowItem *like = [[LLProductArrowItem alloc] initWithTitle:@"赞" icon:@"like"];
    LLProductGroup *group1 = [[LLProductGroup alloc] init];
    group1.items = @[album, collect, like];
    [self.datas addObject:group1];
}

- (void)setupGroup2{
    
    LLProductArrowItem *pay = [[LLProductArrowItem alloc] initWithTitle:@"微博支付"icon:@"pay"];
    
    LLProductArrowItem *vip = [[LLProductArrowItem alloc] initWithTitle:@"个性化" icon:@"vip"];
    
    LLProductGroup *group2 = [[LLProductGroup alloc] init];
    group2.items = @[pay, vip];
    [self.datas addObject:group2];

}

- (void)setupGroup3{
    
    LLProductArrowItem *card = [[LLProductArrowItem alloc] initWithTitle:@"我的名片" icon:@"card"];
    
    LLProductArrowItem *draft = [[LLProductArrowItem alloc] initWithTitle:@"草稿箱" icon:@"draft"];
    
    LLProductGroup *group3 = [[LLProductGroup alloc] init];
    group3.items = @[card, draft];
    [self.datas addObject:group3];

}

#pragma mark - 数据源代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.datas.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    LLProductGroup *group = self.datas[section];
    return group.items.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    LLProductCell *cell = [LLProductCell cellWithTableView:tableView];
    
    LLProductGroup *group = self.datas[indexPath.section];
    cell.item = group.items[indexPath.row];
    return cell;
}


#pragma mark - 设置导航条上的item按钮
/**
 *  设置导航条上的item按钮
 */
- (void)setupRightItem{
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"设置" style:UIBarButtonItemStylePlain target:self action:@selector(setting)];
}

// 点击设置
- (void)setting{
    
    
}

@end
